<?php 
 include_once dirname(__FILE__)."/config.php";
 class ue_support_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_code_ue;
		 protected $_id_support;
		 protected $_etat;
		 public function get_name_table(){ return "ue_support";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function get_name_id_support(){ return "id_support";}
		 public function get_name_etat(){ return "etat";}
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_id_support($parametre){  $this->_id_support=$parametre;}	
		 public function set_etat($parametre){  $this->_etat=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_id_support(){ return $this->_id_support;}
		 public function get_etat(){ return $this->_etat;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 ue_support(
			code_ue,
			id_support,
			etat)
 VALUES(
			'".$this->_code_ue."',
			'".$this->_id_support."',
			'".$this->_etat."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_code_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_ue='".$this->_code_ue."'";
}
if(!empty($this->_id_support)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
id_support='".$this->_id_support."'";
}
if(!empty($this->_etat)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
etat='".$this->_etat."'";
}
$sql="UPDATE 
ue_support SET 
 ".$sql."
								WHERE  ='".$this->_."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
ue_support 
 
									WHERE  ='".$this->_."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
ue_support ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		code_ue,
		id_support,
		etat
 FROM 
 ue_support";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_code_ue=$row->code_ue;
		$this->_id_support=$row->id_support;
		$this->_etat=$row->etat;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>